<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jedrzej\Pimpable\PimpableTrait;

class SystemConfig extends Model
{
    use HasFactory;
    use PimpableTrait;

    public $searchable = [
        'menu_name',
        'type',
        'input_type',
        'category_id',
        'category_name',
    ];

    public $fillable = [
        'menu_name',
        'type',
        'input_type',
        'parameter',
        'upload_type',
        'required',
        'width',
        'height',
        'value',
        'info',
        'desc',
        'system_admin_id'
    ];

    /**
     * 强制转换字段
     */
    public $casts = [
        'value' => 'array'
    ];

    protected $defaultSortCriteria = ['sort,asc'];

    /**
     * 配置所属分类
     */
    public function systemConfigTable()
    {
        return $this->belongsTo(SystemConfigTable::class, 'category_id','id');
    }

}
